package cn.itrip.controller;

import cn.itrip.beans.dto.Dto;
import cn.itrip.beans.vo.hotel.SearchHotelVO;
import cn.itrip.common.DtoUtil;
import cn.itrip.common.EmptyUtils;
import cn.itrip.common.Page;
import cn.itrip.service.HotelSearchService;
import cn.itrip.vo.ItripHotelVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName HotelListController
 * @Description TODO
 * @Author yaozhaobao
 * @Date 2020/12/23 11:21
 * @Version 1.0
 **/
@RestController
@RequestMapping("/api/hotellist")
public class HotelListController {

    @Autowired
    private HotelSearchService hotelSearchService;

    @RequestMapping(value = "/searchItripHotelPage",method = RequestMethod.POST)
    public Dto<ItripHotelVO> searchItripHotelPage(@RequestBody SearchHotelVO searchHotelVO){
        if(EmptyUtils.isEmpty(searchHotelVO.getDestination())){
             return DtoUtil.returnFail("目的地不能为空","20002");
        }
        try {
            //solr搜索
            Page<ItripHotelVO> page = hotelSearchService.getHotelByPage(searchHotelVO);
            return DtoUtil.returnDataSuccess(page);
        }catch (Exception e){
            return DtoUtil.returnFail("未知异常","20001");
        }
    }




}
